import javax.swing.*;
import java.awt.event.*;
import java.io.File;

final class CloseAllItem extends AbstractAction{
  private final Doer frame;
  CloseAllItem(String name,Doer frame){
    super(name);
    this.frame=frame;
    putValue(SHORT_DESCRIPTION,name);
    String iconFileName="images"+File.separator+name+".gif";
    if(new File(iconFileName).exists())putValue(SMALL_ICON,new ImageIcon(iconFileName));
  }

  public void actionPerformed(ActionEvent e){
   closeAllFile();
  }
  public void closeAllFile(){
    int i=frame.getTab().getTabCount()-1;
    while(i>=0){
      frame.getTab().setSelectedIndex(i);
      frame.getCloseItem().closeFile();
      i--;
    }
  }
}
